package com.baidu.service.impl;

import com.baidu.pojo.TbSeller;
import com.baidu.utils.OssUploadTemplate;
import com.baidu.utils.ResultResponse;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baidu.pojo.TbItemCat;
import com.baidu.service.TbItemCatService;
import com.baidu.mapper.TbItemCatMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 *
 */
@Service
public class TbItemCatServiceImpl extends ServiceImpl<TbItemCatMapper, TbItemCat>
    implements TbItemCatService{

    @Autowired
    private TbItemCatMapper itemCatMapper;

    @Autowired
    private OssUploadTemplate ossUploadTemplate;

    @Override
    public ResultResponse getItemList(Integer parentId) {

        QueryWrapper<TbItemCat> queryWrapper = new QueryWrapper<TbItemCat>().eq("parentId", parentId);

        List<TbItemCat> tbItemCats = itemCatMapper.selectList(queryWrapper);

        return ResultResponse.SUCCESS(tbItemCats);

    }

    @Override
    public ResultResponse delImages(String file) {
        return ossUploadTemplate.deleteFileObjectStorage(file);
    }

    @Override
    public ResultResponse uploadImages(MultipartFile file) {
        return ossUploadTemplate.uploadFileObjectStorage(file);
    }


}




